package com.duartepeixinho.P3D.Objects 
{
	import com.duartepeixinho.P3D.Scenes.Scene;
	/**
	 * ...
	 * @author Duarte Peixinho
	 */
	public class Objects
	{
		
		protected var _do3d:Array = new Array();
		protected var _scene:Scene;
		
		public function Objects() 
		{
			
		}
		
		/**
		 * AddChild
		 * @param	do3d	DisplayObject3D
		 */
		public function addChild(do3d:DisplayObject3D):void {
			// removes if exists
			removeChild(do3d);
			
			_do3d.push(do3d);
			do3d.scene = _scene;
		}
		
		/**
		 * getChilds
		 * @return			Array	List of Childs
		 */
		public function getChilds():Array {
			return _do3d;
		}
		
		/**
		 * Removes Child From Scene
		 * @param	dod3d	DisplayObject3D
		 */
		public function removeChild(dod3d:DisplayObject3D):void {
			for (var i:uint = 0; i < _do3d.length; i++) {
				if (_do3d[i] == dod3d) {
					_do3d.splice(i, 1);
					dod3d.scene.removeChild(dod3d);
					dod3d.scene = null;
				}
			}
		}
		
	}

}